<?php
	namespace Common\Logic;
	use Common\Model\UserCardLogsModel;
	class UserCardLogsLogic extends UserCardLogsModel{
		/*
		* Function:		getUserCardLogsList
		* Description:	用户会员卡日志列表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getUserCardLogsList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getUserCardLogsFilter($filter);
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getUserCardLogsFilter
		* Description:	用户会员卡日志列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getUserCardLogsFilter($filter = ''){
			$conditon = array();
			$conditon['status'] = 1;
			if(!empty($filter['user_id'])){
				$conditon['user_id'] = $filter['user_id'];
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getUserCardLogsCount
		* Description:	用户会员卡日志列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getUserCardLogsCount($filter = ''){
			$conditon = $this->getUserCardLogsFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addUserCardLogs
		* Description:	增加用户会员卡日志
		* @param:		$data array 增加的数组
		*/
		public function addUserCardLogs($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getUserCardLogsInfo
		* Description:	获取用户会员卡日志信息 by row
		* @param:		$id int ID
		*/
		public function getUserCardLogsInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateUserCardLogs
		* Description:	更新用户会员卡日志
		* @param:		$data array 更新的数组
		*/
		public function updateUserCardLogs($data){
			return $this->save($data);
		}
		
		/*
		* Function:		deleteUserCardLogs
		* Description:	删除用户会员卡日志
		* @param:		$id int ID
		*/
		public function deleteUserCardLogs($id){
			return $this->where(array('id'=>$id))->delete();
		}
	}
?>